package com.java.sample.domain.bak;

import javax.management.*;
import javax.management.remote.*;

public class WMIQuery {
    public static void main(String[] args) throws Exception {
        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi");
        JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
        MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();

        // 查询 Win32_ComputerSystem 获取域信息
        ObjectName query = new ObjectName("root/cimv2:Win32_ComputerSystem");
        String domain = (String) mbsc.getAttribute(query, "Domain");
        System.out.println("Domain: " + domain);

        jmxc.close();
    }
}
